<%@ page language="java"  pageEncoding="utf-8"%>
<%@ page import="com.ejoysoft.wlanyz.business.Ac,java.util.Iterator,java.util.Set,java.util.ArrayList,java.util.Map,com.ejoysoft.wlanyz.business.Paper,com.ejoysoft.wlanyz.business.Ap,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException" %>
<%@page import="java.util.Vector"%>
<%@ include file="../include/jsp/head.jsp"%>
<%
if(!globa.userSession.hasRight("40005"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
%>

<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
String classOneAc = ParamUtil.getString(request,"strHotSpot","").trim();//获取一级热点;
String classTwoAc = ParamUtil.getString(request,"classTwoAc","").trim();//获取二级热点;
Paper obj1=new Paper(globa);
ArrayList<Object[]> classOneList = obj1.getAllclassoneByName("");
Ap obj2 = new Ap(globa);
Map<String, ArrayList<String>> classTwoMap= obj2.getAllclassTwoByName();
%> 

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
<link href="../css/main.css" rel="stylesheet" type="text/css" />
<script src="../scripts/jsframework.js"></script>
<script language="JavaScript" src="../js/jquery-1.4.1.min.js"></script>
<script src="../scripts/jquery-1.4.1.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<style type="text/css">
body {
	background-color: #f2f8ff;
}
.sel1{ width:160px;}
.STYLE1 {color: #FF0000}
a{ font-size:12px; color:#214263; text-decoration:none; }
a:hover{ font-size:12px; color:#ffffff; background-color:#ff9900; text-decoration:none;display:block;} 
</style>
<script src="../include/js/chkFrm.js"></script>
   <%
	 Ac obj = new Ac(globa);
	 ArrayList<String> listCities = obj.listAllCitys(""); 
	 if(listCities != null)
	 {
	%>

	<script language="javascript"> 

					  var data={};
					  data["-1_beijing"] = "text:北京市;url:javascript:void(0);target:mainFrame;";
					  data['<%="beijing_"+"朝阳区"+"cityName"%>'] = "text:"+'朝阳区'+";target:mainFrame;";
					  data['<%="朝阳区"+"cityName_"+"三里屯街道"+"countyName"%>'] = "text:"+'三里屯街道'+";target:mainFrame;";
					  <%
							String tempString1 ="namestart"+"智畅公司" + "nameendimport";
						%>
					  data['<%="三里屯街道"+"countyName_"+tempString1%>'] = "text:"+'智畅公司'+";target:mainFrame;";
					  
					  data["-1_jiangsu"] = "text:江苏省;url:javascript:void(1);target:mainFrame;";
								<%
			 						for(int k=0;k<listCities.size();k++)
			 						{
										String cityName = listCities.get(k);
										ArrayList<String> listCountries = obj.listCountriesOfCity(" where strCity='"+cityName+"'");
										%>
										 	 data['<%="jiangsu_"+cityName+"cityName"%>'] = "text:"+'<%=cityName%>'+";target:mainFrame;";
										<%
										if(listCountries != null )
										{
											for(int m=0;m<listCountries.size();m++)
											{
												String countryName = listCountries.get(m);
												ArrayList<String> listClassOneAcs = obj.listClassOneAcs(" where strCity='"+cityName+"' and strCountry='"+countryName+"'");
										%>
										 		 data['<%=cityName+"cityName_"+countryName+"countyName"%>'] = "text:"+'<%=countryName%>'+";target:mainFrame;";
										<%
										if(listClassOneAcs !=null)
										{
												for(int m1 = 0 ;m1<listClassOneAcs.size();m1++)
												{
													String oneAcName = listClassOneAcs.get(m1);
													
												 	String tempString ="namestart"+oneAcName+"nameendimport";
												 	
													
										%>
											 		 data['<%=countryName+"countyName_"+tempString%>'] = "text:"+'<%=oneAcName%>'+";target:mainFrame;";
										<%	
												}
											}
										  }
										}		 						
			 						}
			 			%>
			 					  
									
</script>
	<%
	 }
	%>
	<%
	 %>
<script language="javascript">

    function chkFrm() {
   // for(var d=0;d<5;d++)alert(d);
   
       if(trim(frm.strHotSpot.value)=="") {
            alert("请选择一级热点！！！")
            frm.strHotSpot.focus();
            return false;
        }
        if(trim(frm.classTwoAc.value)=="") {
            alert("请选择二级热点！！！")
            frm.classTwoAc.focus();
            return false;
        }
         if(trim(frm.strName.value)=="") {
            alert("请选择测试AP！！！")
            frm.strName.focus();
            return false;
        }
  var input = document.getElementsByTagName("input");   
  var count = 0;        
  var  TestContent = "";    
      for(var i = 0; i < input.length; i ++)         
  {          
     if(input[i].type == "checkbox" && input[i].id.indexOf("strTest") != -1)//判断id为strTest的checkbox      
 {     
 if (input[i].checked)  
           {     //这个地方是获取你选定了的的checkbox的Value                           
//txt1.value=input[i].value;
  if( count == 0){
 var TestContent =  TestContent  + input[i].value;
              count ++; 
 }else if(count > 0){
 var TestContent =  TestContent+ ","  + input[i].value;
              count ++; 
 }
 }
}   
        }    
           if(count == 0) 
          {          
     alert("请选择您的测试任务！"); 
              return false;         
    }  
      document.getElementById("strTestContent").value=TestContent;
      	frm.submit();         
    }
    
    function getAcName1()
 {
 
    var classoneac1 = document.getElementById("strHotSpot").value ;
   	$("#classTwoAc").html("");
	$("#classTwoAc").append("<option value=''>- - - - -请选择- - - - -</option>");
   if(classoneac1 != null && classoneac1!="" && classoneac1 == "智畅公司"){
			$("#classTwoAc").append("<option value='智畅公司亚洲分部'>智畅公司亚洲分部</option>");
			}else{
 	<%
 		for (int j = 0; j <  classOneList.size(); j++) {
			String hotspotone = (String)(classOneList.get(j)[0]);//
			
			ArrayList<String> classtwoac = (ArrayList<String>)(classOneList.get(j)[1]);
			%>
			if(classoneac1 != null && classoneac1!="" && classoneac1 == '<%=hotspotone%>')
			{
			<%
			  for(int i=0;i<classtwoac.size();i++){
			%>
				var tempCountry = '<%=classtwoac.get(i)%>'; 
				$("#classTwoAc").append("<option value='<%=classtwoac.get(i)%>'><%=classtwoac.get(i)%></option>");
			<%
			  }
			%>
			} 
			
			<%
		}
 		%>
 		}
 }
   function getAPName()
 {
    var classtwoac = document.getElementById("classTwoAc").value ;
   	$("#strName").html("");
	$("#strName").append("<option value=''>- - - - -请选择- - - - -</option>");
	if(classtwoac != null && classtwoac!="" && classtwoac == "智畅公司亚洲分部"){
			$("#strName").append("<option value='zhichang'>zhichang</option>");
			}else{
	<%
	    Set<Map.Entry<String, ArrayList<String>>> set = classTwoMap.entrySet();
        for (Iterator<Map.Entry<String, ArrayList<String>>> it = set.iterator(); it.hasNext();) {
            Map.Entry<String, ArrayList<String>> entry = (Map.Entry<String, ArrayList<String>>) it.next();
            String hotspot = entry.getKey();
            ArrayList <String>list = entry.getValue();
     %>
        if(classtwoac != null && classtwoac != "" && classtwoac == '<%=hotspot%>')
        {
        <%
	        for(int i = 0; i < list.size(); i++){
        %>
				$("#strName").append("<option value='<%=list.get(i)%>'><%=list.get(i)%></option>");
        <%
        }
        %>
        }
        <% 
        }
        %>
        }
 }

    
</script>
<script>
var isIe=(document.all)?true:false;
//设置select的可见状态
var j=1;
function setSelectState(state)
{
var objl=document.getElementsByTagName('select');
for(var i=0;i<objl.length;i++)
{
//alert();
objl[i].style.visibility=state;
}
}

//弹出方法
function showMessageBox(e,wWidth,wHeight)
{ 

	closeWindow();
	var bWidth=parseInt(document.documentElement.scrollWidth);
	var bHeight=parseInt(document.documentElement.scrollHeight);
	if(isIe){ 
		setSelectState('hidden');
	}
	var back=document.createElement("div");
	back.id="back";
	var styleStr="top:0px;left:0px;position:absolute;background:#666;width:"+bWidth+"px;height:"+bHeight+"px;";
	styleStr+=(isIe)?"filter:alpha(opacity=0);":"opacity:0;";
	back.style.cssText=styleStr;
	document.body.appendChild(back);
	showBgSuddenlly(back,50);//背景突然变暗
	//showBgGradually(back,50);//背景逐渐变暗
	var mesW=document.createElement("div");
	//---------------------

	//---------------------
	mesW.id="mesWindow";
	mesW.className="mesWindow";  
    Using("System.Web.UI.WebControls.MzTreeView");
    var a = new MzTreeView("");
    a.dataSource = data ;
    a.autoSort=true;
    a.useCheckbox=true
    a.canOperate=true;   // alert(a.render())
    var tempString="";
	 tempString =  tempString+ "<div id='contentDiv' class='mesWindowTop'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' bgcolor='8FA6BD' >"+
                                    "<tr>  <td class='layertit'><table width='100%' height='32' border='0' cellpadding='0' cellspacing='0'><tr>";
	tempString  = tempString+ "<td class='tit'><strong><font style='font-size:14px' color='#FFFFFF'>热点选择  </font></strong></td>" + 
						                             	"<td swidth='28%' align='right' class='layri'onclick='closeWindow();'style='cursor:hand'><img src='../images/layer_gb.jpg'  title='关闭窗口'  /><font  color='#FFFFFF'>关闭</font></td>";
	tempString = tempString + "</tr></table></td></tr><tr> <td background='../images/layer_bg.jpg' class='listd'><table id='resultTable' width='100%' border='0' align='center' cellpadding='0' cellspacing='0'>"+
						            "<tr> <td> "+a.render()+"</td></tr>" + 
						            "<tr><td><img src='../images/layer_bot.png' width='400' height='6' /></td></tr></table></td></tr></table></td></tr> </table> </div>";
				          
	mesW.innerHTML=tempString; 
	   var   t=e.offsetTop; 
	   var   l=e.offsetLeft; 
	  //  alert(e.offsetTop);
	   while(e=e.offsetParent){ 
	        t+=e.offsetTop; 
	        l+=e.offsetLeft; 
	        } 
	var leftPoint = l;
	var topPoint = t;
	
	styleStr="left:"+leftPoint+"px;top:"+topPoint+"px;position:absolute;width:"+wWidth+"px;";
	mesW.style.cssText=styleStr;
	document.body.appendChild(mesW); 
    a.expandLevel(2);//梅花树展开
	
}
//让背景渐渐变暗
function showBgGradually(obj,endInt)
{
if(isIe)
{
	obj.filters.alpha.opacity+=1;
	if(obj.filters.alpha.opacity<endInt)
	{
		setTimeout(function(){showBgGradually(obj,endInt)},5);
	}
}else{
	var al=parseFloat(obj.style.opacity);
	al+=0.01;
	obj.style.opacity=al;
	if(al<(endInt/100))
	{
		setTimeout(function(){showBgGradually(obj,endInt)},5);}
	}
}

//让背景突然变暗
function showBgSuddenlly(obj,endInt)
{
	if(isIe)
	{
		obj.filters.alpha.opacity += endInt;//背景突然变暗
	}else{
		var al=parseFloat(obj.style.opacity);
		al+=0.01*endInt;
	 	obj.style.opacity=al;//背景突然变暗
		 
	}
}
//关闭窗口
function closeWindow()
{


if(document.getElementById('back')!=null)
{
document.getElementById('back').innerHTML="";
document.getElementById('back').parentNode.removeChild(document.getElementById('back'));


}
if(document.getElementById('mesWindow')!=null)
{
document.getElementById('mesWindow').innerHTML="";
document.getElementById('mesWindow').parentNode.removeChild(document.getElementById('mesWindow'));

}

if(isIe){
	 setSelectState('');
	}
	
}

//弹出窗口
function testMessageBox(e)
{

	//var objPos = mousePosition(ev); 
	//showMessageBox(objPos,400,200);
	showMessageBox(e,400,200);

}
//添加图片
</script>
</head>

<body>

<form name="frm" method=post action="task_act.jsp"  >

<input type="hidden" name="<%=Constants.ACTION_TYPE%>" value="<%=Constants.ADD_STR%>"></input>
<input type="hidden" id="strTestContent" name="strTestContent" value="TestContent"/>
<div class="lf_list">
<table width="97%" border="0" align="center" cellpadding="0" cellspacing="0">

  <tr>
    <td height="30"><img src="../images/ri_list.jpg" width="14" height="14" align="bottom" />&nbsp;<font size="2px">您现在所在的位置：</font><font color="#0e7cc9" size="2px">资源管理 </font><font size="2px">&gt; AP任务查询</font><font size="2px">&gt; 添加任务</font></td>
  </tr>
</table>
<table id="tb" width="97%" border="0" align="center" cellpadding="0" cellspacing="0">
 <tr> <td class="listtit1"align="left">&nbsp; &nbsp;<font size="2px"> 任务导入</font></td>
</tr>
 
  <tr>
    <td bgcolor="#FFFFFF" class="listd" style="border-left:1px solid #dddddd;border-right:1px solid #dddddd;">&nbsp;
   
    <table width="92%" border="0" align="center" cellpadding="0" cellspacing="0">        
     <tr>
       <td >
       <table width="99%" border="0" align="center" cellpadding="0" cellspacing="0" style="margin:10px 0px 2px 0px;">
       <tr>
	     <td width="4%" align="left" >
	     </td>

		</tr>
       </table></td></tr>

          <tr>
            <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="25%" height="30" align="right" class="left_txt2"><font size="2px">一级热点：</font></td>
                <td width="3%">&nbsp;</td>
                <td width="32%" height="30">
                <input id="strHotSpot" name="strHotSpot" type="text" value="" class="input_box" size="30" onfocus="testMessageBox(this)" /></td>
               <td> <input id="strHotSpotId" name="strHotSpotId" type="hidden" value="" /></td>
                <td height="30" class="left_txt">&nbsp;</td>
              </tr>
             <tr>

            <td width="35%" height="30" align="right" class="left_txt2" ><font size="2px">二级热点：</font></td>
             <td width="3%">&nbsp;</td>
            <td width="40%" height="30">
            <select id="classTwoAc" name="classTwoAc"   style="width:215px"  class="sel1" onfocus="getAcName1()" >
            <option value=''>- - - - -请选择- - - - -</option>
                            
         </select></td>
         </tr>
         <tr>
             <td width="35%" height="30" align="right" class="left_txt2" ><font size="2px">AP名称 ：</font></td>
             <td width="3%">&nbsp;</td>
            <td width="40%" height="30">
            <select id="strName" name="strName"   style="width:215px"  class="sel1" onfocus="getAPName()" ><option value=''>- - - - -请选择- - - - -</option>
                              
         </select></td>
         </tr>
               <tr> <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">选择类型：</font></td>
                <td width="3%">&nbsp;</td>
                <td align="left"height="30">
                   <input  type="checkbox" value="同频干扰"  id="strTest" name="strTest" /><font size="2px">同频干扰</font><br/>
                   <input  type="checkbox" value="邻频干扰"   id="strTest" name="strTest"/><font size="2px">邻频干扰</font><br/>
                   <input  type="checkbox" value="AP关联测试"   id="strTest" name="strTest"/><font size="2px">AP关联测试</font><br/>
             </td></tr>
            <tr>
               <td width="35%" height="30" align="right" class="left_txt2"><font size="2px">任务描述：</font></td>
                <td width="3%">&nbsp;</td>
                <td align="left">
                      <textarea id="strDesc" name="strDesc"   class="input_box" rows="5" cols="25"/></textarea>
            </td> </tr>
            <tr>
              <td height="30" colspan="3">&nbsp;</td>
            </tr>
            </table>
           <table width="100%" border="0" cellspacing="0" cellpadding="0">
              <tr>
               <td width="3%" >&nbsp; <br></td>
              <td width="40%" height="20" align="right"> <input name="B1" type="button"   value="确  定" onclick="chkFrm()"  class="ipt2" /></td>
               <td width="3%" >&nbsp; <br></td>
               <td width="32%" height="20"><input  name="B12" type="reset"  value="取 消" class="ipt2" /></td>
               <td height="30" class="left_txt2">&nbsp;</td>               
            </tr> 
            </table>
            </td>
          </tr>
        </table>
  
</td>
  </tr>
 
</table>
 </div>
<p><br />
</p>
    </form>
 
</body>
</html>
<%@ include file="../include/jsp/footer.jsp"%>
